import os
import pytest


def create_structure(base_path):
    # 创建 tests 目录
    tests_path = os.path.join(base_path, 'tests')
    os.makedirs(tests_path, exist_ok=True)

    # 创建 tests/__init__.py
    with open(os.path.join(tests_path, '__init__.py'), 'w') as f:
        pass

    # 创建 tests/conftest.py
    with open(os.path.join(tests_path, 'conftest.py'), 'w') as f:
        pass

    # 创建 tests/pages 目录
    pages_path = os.path.join(tests_path, 'pages')
    os.makedirs(pages_path, exist_ok=True)

    # 创建 tests/pages/__init__.py
    with open(os.path.join(pages_path, '__init__.py'), 'w') as f:
        pass

    # 创建 tests/pages/base_page.py
    with open(os.path.join(pages_path, 'base_page.py'), 'w') as f:
        pass

    # 创建 tests/pages/login_page.py
    with open(os.path.join(pages_path, 'login_page.py'), 'w') as f:
        pass

    # 创建 tests/pages/dashboard_page.py
    with open(os.path.join(pages_path, 'dashboard_page.py'), 'w') as f:
        pass

    # 创建 tests/fixtures 目录
    fixtures_path = os.path.join(tests_path, 'fixtures')
    os.makedirs(fixtures_path, exist_ok=True)

    # 创建 tests/fixtures/__init__.py
    with open(os.path.join(fixtures_path, '__init__.py'), 'w') as f:
        pass

    # 创建 tests/fixtures/common_fixtures.py
    with open(os.path.join(fixtures_path, 'common_fixtures.py'), 'w') as f:
        pass

    # 创建 tests/test_cases 目录
    test_cases_path = os.path.join(tests_path, 'test_cases')
    os.makedirs(test_cases_path, exist_ok=True)

    # 创建 tests/test_cases/__init__.py
    with open(os.path.join(test_cases_path, '__init__.py'), 'w') as f:
        pass

    # 创建 tests/test_cases/test_login.py
    with open(os.path.join(test_cases_path, 'test_login.py'), 'w') as f:
        pass

    # 创建 tests/test_cases/test_dashboard.py
    with open(os.path.join(test_cases_path, 'test_dashboard.py'), 'w') as f:
        pass

    # 创建 tests/page_factory.py
    with open(os.path.join(tests_path, 'page_factory.py'), 'w') as f:
        pass

    # 创建 resources 目录
    resources_path = os.path.join(base_path, 'resources')
    os.makedirs(resources_path, exist_ok=True)

    # 创建 resources/data 目录
    data_path = os.path.join(resources_path, 'data')
    os.makedirs(data_path, exist_ok=True)

    # 创建 resources/data/test_loginy.yaml
    with open(os.path.join(data_path, 'test_loginy.yaml'), 'w') as f:
        pass

    # 创建 utils 目录
    utils_path = os.path.join(base_path, 'utils')
    os.makedirs(utils_path, exist_ok=True)

    # 创建 utils/__init__.py
    with open(os.path.join(utils_path, '__init__.py'), 'w') as f:
        pass

    # 创建 utils/config.py
    with open(os.path.join(utils_path, 'config.py'), 'w') as f:
        pass

    # 创建 utils/logger.py
    with open(os.path.join(utils_path, 'logger.py'), 'w') as f:
        pass

    # 创建 requirements.txt
    with open(os.path.join(base_path, 'requirements.txt'), 'w') as f:
        pass

    # 创建 pytest.ini
    with open(os.path.join(base_path, 'pytest.ini'), 'w') as f:
        pass

    # 创建 test-results 目录
    test_results_path = os.path.join(base_path, 'test-results')
    os.makedirs(test_results_path, exist_ok=True)

    # 创建 allure-report 目录
    allure_report_path = os.path.join(base_path, 'allure-report')
    os.makedirs(allure_report_path, exist_ok=True)

    # 创建 Jenkinsfile
    with open(os.path.join(base_path, 'Jenkinsfile'), 'w') as f:
        pass


# 设置基础路径
base_path = 'my_web_test_project'

# 创建目录结构
create_structure(base_path)

print("Automation framework directory structure created successfully.")